package com.docmgmt.mvp.dto;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result<T> {
    private String code;
    private String message;
    private T data;

    public static <T> Result<T> success() {
        return new Result<>("SUCCESS", "Operation successful", null);
    }

    public static <T> Result<T> success(T data) {
        return new Result<>("SUCCESS", "Operation successful", data);
    }

    public static <T> Result<T> success(String message, T data) {
        return new Result<>("SUCCESS", message, data);
    }

    /**
     * 成功响应（仅消息，无数据）
     * 用于返回Result<Void>的场景
     */
    public static Result<Void> success(String message) {
        return new Result<>("SUCCESS", message, null);
    }

    /**
     * 错误响应（仅消息）
     */
    public static <T> Result<T> error(String message) {
        return new Result<>("ERROR", message, null);
    }

    public static <T> Result<T> error(String code, String message) {
        return new Result<>(code, message, null);
    }

    public static <T> Result<T> error(String code, String message, T data) {
        return new Result<>(code, message, data);
    }

    public static <T> Result<T> forbidden(String message) {
        return new Result<>("FORBIDDEN", message, null);
    }
}
